package com.aabte.auth.event.model;

import com.aabte.auth.shared.model.BaseModelUseLongPK;
import com.aabte.commons.ddd.shared.DomainEntity;
import lombok.Getter;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.time.Instant;

@SuppressWarnings("all")
@Entity
@Table(name = "tb_store_event")
@Getter
@ToString
public class StoredEvent extends BaseModelUseLongPK implements DomainEntity<StoredEvent, String> {
    @Column(length = 32)
    private String eventId;
    private String typeName;
    private String eventBody;
    private Instant occurredOn;

    private StoredEvent() {
    }

    public StoredEvent(String eventId, String typeName, String eventBody, Instant occurredOn) {
        this.eventId = eventId;
        this.typeName = typeName;
        this.eventBody = eventBody;
        this.occurredOn = occurredOn;
    }

    @Override
    public boolean sameIdentityAs(StoredEvent event) {
        return this.eventId.equals(event.eventId);
    }

    @Override
    public String identity() {
        return this.eventId;
    }
}
